$(function(){
    // load setting value
    $(document).on('pageshow', '#pageSetting', function(event){
        PageChangeController.prototype.freeMemory();
        monaca.updateUIStyle("titlelable", "text", "設定");
        monaca.updateUIStyle("backheader", "visibility", "true");
        monaca.updateUIStyle("footer", "visibility", "false");
        
        Util.prototype.changeSnapperElement("setting-content");
        
        var allow = SettingService.prototype.getLocationAllow();
        if (allow == "許可") {　// 許可
            $("#position-allow-box").attr("checked", allow).checkboxradio("refresh");
        } else { // 拒否
            $("#position-allow-box").removeAttr("checked").checkboxradio("refresh");
        }
        
        Util.prototype.hideSpinner();
    });
    
    /**
     * update position-allow value when event change on position-allow-checkbox
     */
    $("#position-allow-box").bind( "change", function(event, ui) {        
        var allow = $(this).is(':checked') ? "許可" : "拒否";
        SettingService.prototype.setLocationAllow(allow);
    }); 
    
    /**
     * show dialog when click on licene object
     */
    $('#setting-listview').delegate('li', 'click', function () {
        if ($(this).attr('id') === "license") {
            navigator.notification.alert(
                "アプリアイコン\n-http://icons8.com/license/icons8\n" + 
                "-http://www.icons-land.com/\n\n" + 
                "地図画像\n-http://www.sekaichizu.jp/\n" + 
                "-http://www.craftmap.box-i.net/\n\n",
                null, "ライセンス情報"); 
        }
    });
});
